home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
boe.pres.k12.wv.us
/
boe.pres.k12.wv.us.zip
/
boe.pres.k12.wv.us
/
Utilities
/
Xerox Workcentre 5335
/
Windows Scan
/
32-bit_x86
/
Francais
/
cpsimage.cab
/
data
/
xps
/
fiji2xps.elf
next >
Wrap
Text File
|
2009-03-16
|
2KB
|
81 lines
/*
** What this script is for:
** Write single page XPS output format by reading input image, segments
** using fiji nlayer, added thumbnail, and does OCR if option asked for.
** NOTE: this script assumes that the input image is a single image raster
** format supported by XIPS. For example, jpeg, tiff, png, gif, etc.
*/
// The TimeCheck() function reports the time to this point in the execution
print "time to start interpreter = " + TimeCheck() + "secs";
// Load scripted support procedures
//#load "xipProcs/printLayer.proc";
#load "xps/xmetWriteXPS.proc"; // XPS support procs
// Import FIJI definitions
#import "fiji2xip.ucm";
#import "fwx2xip.ucm";
// Import XEngine image processing definitions
LoadClasses ( filename: "xeng");
#load "xipProcs/getOcrPage.proc";
///////////////// Main Program ////////////////////////////////////////
// Importable value for variable "image"
IMPORT STRING image;
IMPORT STRING language = "English";
IMPORT INTEGER ocr = 1; // Default is on
STRING ocrformat = "XDOC";
STRING ocrxdoc, ocrxml;
// Test for proper parameters
if ( !image) {
print "Usage: \"xipe fiji2xps.elf -im image:s filename language:s language ocr:i 0|1\" ";
end;
}
// Set output filename
STRING outxps = image.name() + ".xps";
// Read and segment image
XIPIMAGE img = readimage (filename: image );
// Get thumbnail
XIPIMAGE thumb = img.thumbnail();
// See fijiSeg method for documentation on arguments
print "FIJI Segmentation ...";
XIPIMAGE ims = img.fijiSeg (cfgfile: "$XIPTOP/data/fiji/fijiNl.cfg");
print "Segmented image has " + ims.nlayers + " layers";
// Add thumbnail to segmented image
ims.addLayer(image:thumb, ltype: XIP_Thumbnail);
if ( ocr ) {
print "OCR ...";
XIPIMAGE ocrimg = getOcrPage (input:ims);
ocrxdoc = ocrimg.fwxOCR (texttype: ocrformat, language: language);
XIPIMAGE ocrxip = XDOCtoXIPXML(xdoc: ocrxdoc);
ims.addLayer(image:ocrxip, ltype: XIP_Text);
}
print "WriteXPSOpen";
WriteXPSOpen(filename: outxps);
print "WriteXPSPage";
/* 8.5x 11 page DOUBLE page_x = 215.9; DOUBLE page_y = 279.4; */
DOUBLE page_x = 0; //Auto mode
DOUBLE page_y = 0;
WriteXPSPage(filename: outxps, img: ims, pgNum: 1, page_x: page_x, page_y: page_y);
print "WriteXPSClose";
WriteXPSClose(filename: outxps);
// How long has this taken
print TimeCheck();
print "output xps file = " + outxps;